package com.gopay.common.trace.hessian;

import com.caucho.services.server.ServiceContext;
import com.gopay.common.hessian.ReceiveHessianKey;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 因为系统中存在两种使用 方式 故与先系统同保持一致，重写了两个exporter类
 *
 * @author ddh02
 * @LogBaseHessianServiceExporter
 * @2017/4/7 10:38  www.gopay.com.cn Inc.All rights reserved.
 */


public class GopayLogHessianServiceExporter extends LogHessianServiceExporter {

    //private static final Logger logger = LoggerFactory.getLogger(GopayLogHessianServiceExporter.class);

    @Override
    public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            String tokenKey = request.getHeader("Token-Key");
//            logger.error("Token-Key:" + tokenKey);
            ReceiveHessianKey.getInstance(tokenKey);

            // 调用spring自身的实现
            super.handleRequest(request, response);

        } finally {
            ServiceContext.end();
        }
    }
}
